class Solution:
    def isSymmetric(self, root: TreeNode) -> bool:
        if not root:
            return True

        queue = [(root.left, root.right)]
        while queue:
            left, right = queue.pop(0)
            if not left and not right:  # 都为空则跳过
                continue
            if not left or not right:  # 单边为空则不对称
                return False
            if left.val != right.val:  # 值不相等则不对称
                return False
            # 按镜像顺序添加节点对
            queue.append((left.left, right.right))
            queue.append((left.right, right.left))
        return True
